<template>
  <div>
    <div class="tab">
      <van-tabs v-model="active" background="#222222" color="#ffcd32">
        <van-tab>
          <template #title>
            <router-link
              active-class="active-router"
              class="tab-item"
              to="/recommend"
            >
              推荐
            </router-link>
          </template>
        </van-tab>
        <van-tab>
          <template #title>
            <router-link
              active-class="active-router"
              class="tab-item"
              to="/singer"
            >
              歌手
            </router-link>
          </template>
        </van-tab>
        <van-tab>
          <template #title>
            <router-link
              active-class="active-router"
              class="tab-item"
              to="/ranking"
            >
              排行
            </router-link>
          </template>
        </van-tab>
        <van-tab>
          <template #title>
            <router-link
              active-class="active-router"
              class="tab-item"
              to="/search"
            >
              搜索
            </router-link>
          </template>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      active: 0,
      pathList: [
        { path: "/recommend", active: 0 },
        { path: "/singer", active: 1 },
        { path: "/ranking", active: 2 },
        { path: "/search", active: 3 },
      ],
    };
  },
  created() {},
  watch: {
    $route() {
      this.pathList.forEach((ele) => {
        if (ele.path == this.$route.path) {
          this.active = ele.active;
          return;
        }
      });
    },
  },
};
</script>
<style lang="less" scoped>
@import "@styles/index.less";
.tab {
  background: @bgcolor;
  .tab-item {
    color: rgba(225, 225, 225, 0.6);
  }
  /deep/.van-tabs {
    .van-tabs__line {
      z-index: 0;
      bottom: 20px;
    }
  }
  .active-router {
    color: @c;
  }
}
</style>
